#ifndef _SCHED_H_
#define _SCHED_H_

#include "types.h"
#include "time.h"
#include "string.h"

/* RTOS default scheduler configuration */
#ifndef SCHED_PARAM_SS
    #define SCHED_PARAM_SS                     0
#endif

enum {
	SCHED_FIFO = 0,    /* first in-first out (FIFO) scheduling policy. */
	SCHED_RR,          /* round robin scheduling policy */
	SCHED_SPORADIC,    /* sporadic server scheduling policy */
	SCHED_OTHER        /* another scheduling policy */
};

struct sched_param {
	/* process or thread execution scheduling priority */
	int                                     sched_priority;

	/* process or thread execution scheduling current priority */
	int                                     sched_curpriority;

#if SCHED_PARAM_SS
	/* low scheduling priority for sporadic server */
	int                                     sched_ss_low_priorit;

	/* replenishment period for sporadic server */
	struct timespec                         sched_ss_repl_period;

	/* initial budget for sporadic server */
	struct timespec                         sched_ss_init_budget;

	/* Maximum pending replenishments for sporadic server */
	int                                     sched_ss_max_repl;
#endif
};

#define SCHED_SET_SCHEDPRIORITY(a, b) \
    (a)->sched_priority = (b)
      
#define SCHED_INIT_PARAM(a) \
    memset((a), 0, sizeof(struct sched_param))

int sched_get_priority_max(int);
int sched_get_priority_min(int);
int sched_getparam(pid_t, struct sched_param *);
int sched_getscheduler(pid_t);
int sched_rr_get_interval(pid_t, struct timespec *);
int sched_setparam(pid_t, const struct sched_param *);
int sched_setscheduler(pid_t, int, const struct sched_param *);
int sched_yield(void);

/*****************************************************************************/

#endif
